package com.ss.android.article.browser.search;

import android.support.annotation.NonNull;
import com.a.a.NightMode;
import com.a.a.u;
import com.ss.android.article.browser.database.BrowserHistory;

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

final class h implements NightMode {
    private final SearchHistoryAdapter b;
    private final String a;

    h(SearchHistoryAdapter arg1, String arg2) {
        this.b = arg1;
        this.a = arg2;

    }

    public final void f(@NonNull Object arg7) {
        int v5 = 5;
        ArrayList v3 = new ArrayList(v5);
        int v1 = 0;
        int v2 = 0;
        while(v1 < b.c(this.b).size()) {
            if(v2 >= v5) {
                break;
            }

            if(((BrowserHistory) SearchHistoryAdapter.c(this.b).get(v1)).title.toLowerCase(Locale.getDefault()).startsWith(this.a)) {
                ((List)v3).add(b.c(this.b).get(v1));
                ++v2;
            }
            else if(((BrowserHistory) SearchHistoryAdapter.c(this.b).get(v1)).url.contains(this.a)) {
                ((List)v3).add(b.c(this.b).get(v1));
                ++v2;
            }

            ++v1;
        }

        ((u)arg7).onItem(v3);
        ((u)arg7).onComplete();
    }
}

